Package cells.charts

Source Code of cells.charts.AsposePivotChart

package cells.charts;

import com.aspose.cells.Chart;
import com.aspose.cells.ChartType;
import com.aspose.cells.SheetType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AsposePivotChart
{
  public static void main(String[] args) throws Exception
  {
    // Instantiating an Workbook object
    Workbook workbook = new Workbook("data/AsposePivotTable.xls");

    // Adding a new sheet
    int sheetIndex = workbook.getWorksheets().add(SheetType.CHART);
    Worksheet sheet3 = workbook.getWorksheets().get(sheetIndex);

    // Naming the sheet
    sheet3.setName("PivotChart");
   
    // Adding a column chart
    int chartIndex = sheet3.getCharts().add(ChartType.COLUMN, 0, 5, 28, 16);
    Chart chart = sheet3.getCharts().get(chartIndex);
   
    // Setting the pivot chart data source
    chart.setPivotSource("PivotTable!PivotTable1");
    chart.setHidePivotFieldButtons(false);
   
    // Saving the Excel file
    workbook.save("data/Aspose_PivotChart.xls");
   
    // Print Message
    System.out.println("Pivot Chart created successfully.");
  }
}
TOP

Related Classes of cells.charts.AsposePivotChart

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.